<?php

/*
 * |--------------------------------------------------------------------------
 * | API Routes，水产供求
 * |--------------------------------------------------------------------------
 * |
 * | Here is where you can register API routes for your application. These
 * | routes are loaded by the RouteServiceProvider within a group which
 * | is assigned the "api" middleware group. Enjoy building your API!
 * |
 */
Route::group([
    'prefix' => 'trade',
    'namespace' => 'Api\Trade'
], function () {
    Route::prefix('index')->group(function () {
        Route::get('getBanner', 'IndexController@getBanner');
        Route::get('getInfoSub', 'IndexController@getInfoSub');
        Route::get('getSupplyList', 'IndexController@getSupplyList');
        Route::get('getDemandList', 'IndexController@getDemandList');
        Route::get('getShopList', 'IndexController@getShopList');
    });
    Route::group([
        'prefix' => 'shop'
    ], function () {
        Route::get('getSupplyList', 'ShopController@getSupplyList');
        Route::get('getDemandList', 'ShopController@getDemandList');
        Route::group([
            'middleware' => 'base.exists.trade.shop'
        ], function () {
            Route::get('getDetail', 'ShopController@getDetail');
        });
    });
    Route::group([
        'prefix' => 'supply'
    ], function () {
        Route::get('getList', 'SupplyController@getList')->middleware('search.keyword.trade');
        Route::group([
            'middleware' => 'base.exists.trade.supply'
        ], function () {
            Route::get('getDetail', 'SupplyController@getDetail')->middleware('awstats.visit.trade.supply');
            Route::get('getDetailSub', 'SupplyController@getDetailSub');
            Route::get('getDetailMoers', 'SupplyController@getDetailMoers');
        });
    });
    Route::group([
        'prefix' => 'demand'
    ], function () {
        Route::get('getList', 'DemandController@getList')->middleware('search.keyword.trade');
        Route::group([
            'middleware' => 'base.exists.trade.demand'
        ], function () {
            Route::get('getDetail', 'DemandController@getDetail')->middleware('awstats.visit.trade.demand');
            Route::get('getDetailSub', 'DemandController@getDetailSub');
            Route::get('getDetailMoers', 'DemandController@getDetailMoers');
        });
    });
    Route::prefix('search')->group(function () {
        Route::get('getHotKeyword', 'SearchController@getHotKeyword');
    });
});

Route::group([
    'prefix' => 'trade',
    'namespace' => 'Api\Trade\Auth',
    'middleware' => 'auth.user'
], function () {
    Route::group([
        'prefix' => 'supply'
    ], function () {
        Route::get('getMyList', 'SupplyController@getMyList');
        Route::get('getCollectionList', 'SupplyController@getCollectionList');
        Route::post('deleteCollection', 'SupplyController@deleteCollection');
        Route::group([
            'middleware' => 'base.exists.trade.supply'
        ], function () {
            Route::post('reportItem', 'SupplyController@reportItem');
            Route::post('collectionItem', 'SupplyController@collectionItem');
            Route::post('dialItem', 'SupplyController@dialItem');
            Route::group([
                'middleware' => 'auth.owner.trade.supply'
            ], function () {
                Route::get('getItem', 'SupplyController@getItem');
                Route::get('getItemMoers', 'SupplyController@getItemMoers');
                Route::post('saveItem', 'SupplyController@saveItem');
                Route::post('banItem', 'SupplyController@banItem');
                Route::post('editItemStatus', 'SupplyController@editItemStatus');
                Route::post('refreshItem', 'SupplyController@refreshItem')->middleware('auth.refresh.trade.supply');
            });
        });
    });
    Route::group([
        'prefix' => 'demand'
    ], function () {
        Route::get('getMyList', 'DemandController@getMyList');
        Route::get('getCollectionList', 'DemandController@getCollectionList');
        Route::post('deleteCollection', 'DemandController@deleteCollection');
        Route::group([
            'middleware' => 'base.exists.trade.demand'
        ], function () {
            Route::post('reportItem', 'DemandController@reportItem');
            Route::post('collectionItem', 'DemandController@collectionItem');
            Route::post('dialItem', 'DemandController@dialItem');
            Route::group([
                'middleware' => 'auth.owner.trade.demand'
            ], function () {
                Route::get('getItem', 'DemandController@getItem');
                Route::get('getItemMoers', 'DemandController@getItemMoers');
                Route::post('saveItem', 'DemandController@saveItem');
                Route::post('banItem', 'DemandController@banItem');
                Route::post('editItemStatus', 'DemandController@editItemStatus');
                Route::post('refreshItem', 'DemandController@refreshItem')->middleware('auth.refresh.trade.demand');
            });
        });
    });
    Route::group([
        'prefix' => 'shop'
    ], function () {
        Route::get('getCollectionList', 'ShopController@getCollectionList');
        Route::post('deleteCollection', 'ShopController@deleteCollection');
        Route::group([
            'middleware' => 'base.exists.trade.shop'
        ], function () {
            Route::post('collectionItem', 'ShopController@collectionItem');
        });
    });

    Route::prefix('common')->group(function () {
        Route::get('getMyInfo', 'CommonController@getMyInfo');
        Route::get('getFishKindSub', 'CommonController@getFishKindSub');
        Route::get('getDescTagList', 'CommonController@getDescTagList');
        Route::get('getValidityList', 'CommonController@getValidityList');
        Route::get('getTencentAuth', 'CommonController@getTencentAuth');
    });
});

